package com.platform.service.impl;

import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.platform.dao.ClientMessageDao;
import com.platform.entity.ClientMessageEntity;
import com.platform.service.ClientMessageService;

/**
 * Service实现类
 *
 * @author ocean
 * @email 1141736487@qq.com
 * @date 2019-04-09 11:22:18
 */
@Service("clientMessageService")
public class ClientMessageServiceImpl implements ClientMessageService {
    @Autowired
    private ClientMessageDao clientMessageDao;

    @Override
    public ClientMessageEntity queryObject(Integer id) {
        return clientMessageDao.queryObject(id);
    }

    @Override
    public List<ClientMessageEntity> queryList(Map<String, Object> map) {

        Long userId = ShiroUtils.getUserId();
        if(userId == 1){
            map.put("receptionUser", null);
        }else {
            map.put("receptionUser", userId);
        }
        return clientMessageDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return clientMessageDao.queryTotal(map);
    }

    @Override
    public int save(ClientMessageEntity clientMessage) {
        Long userId = ShiroUtils.getUserId();
        clientMessage.setReceptionUser(userId.toString());
        clientMessage.setSubmitTime(new Date());
        return clientMessageDao.save(clientMessage);
    }

    @Override
    public int update(ClientMessageEntity clientMessage) {
        return clientMessageDao.update(clientMessage);
    }

    @Override
    public int delete(Integer id) {
        return clientMessageDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return clientMessageDao.deleteBatch(ids);
    }
}
